import { http } from './service.js'

export const getOrderList = (params) => {
	return http.request({
		url: '/v2/pay/order/list',
		method: 'GET',
		params: params
	})
}

export const getOrder = (params) => {
	console.log(params);
	return http.request({
		url: '/v2/pay/order',
		method: 'GET',
		params: params
	})
}

export const getWxPrepare = (params) => {
	return http.request({
		url: '/v2/pay/wx/prepare',
		method: 'POST',
		params: params
	})
}

export const wxOrderCheck = (outTradeNo) => {
	return http.request({
		url: '/v2/pay/wx/order/check',
		method: 'GET',
		params: {
			outTradeNo: outTradeNo
		}
	})
}

export const getWallet = () => {
	return http.request({
		url: '/v2/pay/wallet',
		method: 'GET'
	})
}

export function getWxConfig(url) {
    let host = window.location.host;
    let appId = 'wxf97f55ca6b448528';
    // if (host.indexOf('emp.dev.tuo51.com') !== -1 || host.indexOf('192.168') !== -1) {
    //     appId = 'wxfdd1bc495a193945';
    // }
	return http.request({
		url: '/wx/portal/' + appId + '/config',
		method: 'get',
		params: {
            appid: appId,
            url: url,
		}
	})
}

export const getAgreementList = () => {
	return http.request({
		url: '/v2/agreement_record/list',
		method: 'GET'
	})
}

export const addAgreementRecord = (data) => {
	return http.request({
		url: '/v2/agreement_record',
		method: 'POST',
		header: {
			'content-type': 'application/x-www-form-urlencoded'
		},
		data
	})
}